﻿using System;
namespace Legend.Caching
{
    /// <summary>
    /// Represents a cache.
    /// </summary>
    public interface ICache
    {
        /// <summary>
        /// Inserts the specified value in the cache. Any existing
        /// value with the specified key will be overwritten.
        /// </summary>
        /// <param name="key">The key used for the item.</param>
        /// <param name="value">The value to cache.</param>
        /// <param name="timeToLive">For how long the value should
        /// exist in the cache before invalidated.</param>
        void Insert(string key, object value, TimeSpan timeToLive);

        /// <summary>
        /// Tries to get the value with the specified key from the cache,
        /// returns true if the value was found and the value is set to
        /// the output variable <paramref name="value"/>.
        /// </summary>
        /// <param name="key">The key of the value to get.</param>
        /// <param name="value">An output variable to store the key by.</param>
        /// <returns>True if a value with the speicified key was found
        /// in the cache.</returns>
        bool TryGetValue(string key, out object value);

        
        /// <summary>
        /// Removes the value with the specified key from the cache.
        /// </summary>
        /// <param name="key">The key of the value to remove.</param>
        void Remove(string key);
    }
}